/*
 * CS_MONTH_CHARGE_EVENT_INFO.cpp
 *
 *  Created on: 2014. 3. 6.
 *      Author: mega
 */

#include "../../User.h"
#include "../../Command.h"
#include "../../NResource/Static.h"

namespace ProjectZ { namespace NCommand {

static void SendFailMonthChargeEvent(User * pUser, int ack)
{
	::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
	*pAck << static_cast<int16_t>(ack);
	pAck->MakePacket(CMD_SC_MONTH_CHARGE_EVENT_INFO);
	pUser->Send(pAck);
}

void Command::CS_MONTH_CHARGE_INFO(User * pUser, ::Network::Packet * pPacket)
{
/*	CS_MONTH_CHARGE_EVENT_INFO                      0x095b
	{
	}

	SC_MONTH_CHARGE_EVENT_INFO                      0x095c
	{
	           s16  s16ack;
	           str   str_event_url;                              //ack_ok 시 이벤트 url페이지
	}*/

	PREPARE_PACKET;

	// 이미 첫 구매 보상을 받은 경우
	if (true == NResource::Static::Instance().GetMonthChargingResource()->IsRecvMonthChargeEventItem(pUser))
	{
		SendFailMonthChargeEvent(pUser, ACK_NO_DATA);
		return;
	}

	NResource::MonthChargingEventResource::MonthChargingEvent::Flyweight * pFly = NResource::Static::Instance().GetMonthChargingResource()->GetFly(pUser);
	if (NULL == pFly)
	{
		SendFailMonthChargeEvent(pUser, ACK_NO_DATA);
		return;
	}

	::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
	*pAck << static_cast<int16_t>(ACK_OK);
	*pAck << pFly->_URL.c_str();
	pAck->MakePacket(CMD_SC_MONTH_CHARGE_EVENT_INFO);
	pUser->Send(pAck);
}

} /*NCommand*/ } /*ProjectZ*/
